package com.example.demosecurityjwtlogin.repository;

import com.example.demosecurityjwtlogin.models.Book;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface BookMapper {
    @Select("select * from t_book where id=#{id}")
    public Book findById(Integer id);

    @Select("SELECT * FROM t_book")
    public List<Book> getAllBook();

    @Insert("INSERT INTO t_book(name,author,price)" +
            "values (#{name},#{author},#{price})")
    public int addBook(Book book);

    @Update("UPDATE t_book SET name=#{name} ,author=#{author},price=#{price} WHERE id=#{id}")
    public int updateBookById(Book book);

    @Delete("DELETE FROM t_book where id=#{id}")
    public int deleteBookById(int id);

}
